//
//  ZRecordTableViewCell.m
//  DoctorFAQs
//
//  Created by zjq on 17/2/20.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "ZRecordTableViewCell.h"
#import "ZLabelTools.h"
@interface ZRecordTableViewCell (){
    UIView * _garyView;
    UIImageView * _headView;
    UILabel * _nameLabel;
    UILabel * _sexLabel;
    UILabel * _ageLabel;
    UILabel * _timeLabel;
    UIImageView * _rightView;
}

@end
@implementation ZRecordTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initlizeInterface];
    }
    return self;
}
- (void)initlizeInterface {
    [self makeAllSubView];
    [self addAllSubView];
    [self makeAllSubViewMasnoy];
}
- (void)makeAllSubView {
    _garyView = [[UIView alloc] init];
    _garyView.backgroundColor = MYGRAYCOLOR;
    _headView = [[UIImageView alloc] init];
    _headView.image = [UIImage imageNamed:@"comment_tx"];
    _headView.layer.cornerRadius = 25*xsIZE;
    _headView.layer.masksToBounds = YES;

    _nameLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_nameLabel Textcolor:[UIColor blackColor] backColor:[UIColor clearColor] Fontsize:18 context:@"" isCenter:NO];
    _sexLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_sexLabel Textcolor:KHGaryColor666 backColor:[UIColor clearColor] Fontsize:13 context:@"" isCenter:NO];
    _ageLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_ageLabel Textcolor:KHGaryColor666 backColor:[UIColor clearColor] Fontsize:13 context:@"" isCenter:NO];
    _timeLabel = [[UILabel alloc] init];
    [ZLabelTools setThelabel:_timeLabel Textcolor:KHGaryColor backColor:[UIColor clearColor] Fontsize:12 context:@"" isCenter:YES];
    _rightView = [[UIImageView alloc] init];
    _rightView.image = [UIImage imageNamed:@"icon_right_r"];
}
- (void)addAllSubView {
    [self.contentView addSubview:_garyView];
    [self.contentView addSubview:_headView];
    [self.contentView addSubview:_nameLabel];
    [self.contentView addSubview:_sexLabel];
    [self.contentView addSubview:_ageLabel];
    [self.contentView addSubview:_timeLabel];
    [self.contentView addSubview:_rightView];
}
- (void)makeAllSubViewMasnoy {
    [_garyView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self.contentView);
        make.height.offset(10*ysIZE);
    }];
    [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(15*xsIZE);
        make.top.equalTo(_garyView.mas_bottom).offset(15*ysIZE);
        make.width.offset(50*xsIZE);
        make.height.offset(50*xsIZE);
    }];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_headView.mas_right).offset(17*xsIZE);
        make.top.equalTo(_garyView.mas_bottom).offset(23*ysIZE);
        make.width.offset(100*xsIZE);
        make.height.offset(18*ysIZE);
    }];
    [_sexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_nameLabel);
        make.top.equalTo(_nameLabel.mas_bottom).offset(10*ysIZE);
        make.width.offset(20*xsIZE);
        make.height.offset(13*ysIZE);
    }];
    [_ageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_sexLabel.mas_right);
        make.top.height.equalTo(_sexLabel);
        make.width.offset(40*xsIZE);
    }];
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_nameLabel.mas_right);
        make.centerY.top.equalTo(_nameLabel);
        make.width.offset(160*xsIZE);
    }];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

// 重写模型set方法
- (void)setHeathModel:(ZHealthModel *)heathModel {
    _heathModel = heathModel;
    _nameLabel.text = _heathModel.title;
    _sexLabel.text = _heathModel.sex;
    _ageLabel.text = _heathModel.age;
    _timeLabel.text = _heathModel.time;
    NSString *iconStr = [NSString stringWithFormat:@"%@%@",IconURL,_heathModel.pic];
    [_headView sd_setImageWithURL:[NSURL URLWithString:iconStr] placeholderImage:[UIImage imageNamed:@"icon_center_tx"]];
}



@end
